This page last changed on Aug 31, 2009 by aunger.

Per a discussion with Stephen in IRC (http://rails.dev.concord.org/irclog/otrunk/2009-08-28.html#T18-35-44), here's a description of a way to pass session information into a SAIL session and have the info automatically included in HTTP requests made from the Java environment, in effect making the Java code aware of an existing http session.

The CookieService

Initial Implementation

An initial implementation has now been checked in and built. If the sail-data-emf jar has a timestamp after 20090831.181738-37, the HttpCookieService interface, HttpCookieServiceImpl class, and HttpCookieHandler class will be available. For an example of a config which implements some static values, see http://saildataservice.staging.concord.org/config_versions/6.

Configuring

Basically the idea is to create a Cookie SAIL Service which is initialized via the config file which defines the services for a SAIL session. The SDS (or equivalent web app) would embed whatever cookie information it wanted into the config. For example:

<object class="net.sf.sail.emf.launch.HttpCookieServiceImpl">
  <void property="cookieProperties">
    <object class="java.util.Properties">
      <void method="setProperty">
        <string>concord.org</string>
        <string>some_session_key; foo=bar</string>
      </void>
      <void method="setProperty">
        <string>*.some.wildcard.domain.com</string>
        <string>some_other_session_key</string>
      </void>
      <void method="setProperty">
        <string>*</string>
        <string>some_global_cookie_property</string>
      </void>
    </object>
  </void>
</object>

What the service does

The cookie service would take it's set of passed in cookie definitions, and then set up a new java.net.CookieHandler (or it itself could be one), which it then registers as the global CookieHandler via CookieHandler.setDefault(CookieHandler). This CookieHandler would then embed cookies with the appropriate session information on appropriate requests, thus allowing the Java code to continue the existing http session started in the browser.

References

  • Cookie Support in Java Web Start: v1.5, v1.6
Document generated by Confluence on Jan 27, 2014 16:52